package tools.config;

import java.io.*;

public class SerUtil {

    public static  boolean checkFileExists(String filename){
        File var3 = new File(filename);
        if (var3.exists()) {
            return true;
        }
        return false;
    }

    public static Object getDataFromSer(String filename) {
        Object res=new Object();
        try
        {
            FileInputStream fis = new FileInputStream(filename);
            ObjectInputStream ois = new ObjectInputStream(fis);
            res= ois.readObject();
            ois.close();
            fis.close();
        }catch(IOException ioe)
        {
            ioe.printStackTrace();
        }catch(ClassNotFoundException c)
        {
            System.out.println("Class not found");
            c.printStackTrace();
        }
        return res;
    }

    public static void makeSerFile(String filename, Object a) {
        System.out.println("正在生成缓存文件(请耐心等待，为了下次启动更快速)："+filename);
        File var3 = new File(filename);

        try {
            if (var3.exists()) {
                var3.delete();
            }
            FileOutputStream fos = new FileOutputStream(filename);
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(a);
            oos.close();
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

